<template>
  <div class="container">
    <h3 style="text-align:center;">场地类型添加</h3>
    <hr />
    <div id="field_ruleForm" style="margin:auto;text-align:center;width:80%">
      <el-form
        :model="field_ruleForm"
        status-icon
        :rules="rules"
        ref="field_ruleForm"
        inline-message
        class="demo-ruleForm"
      >
        <el-form-item prop="name">
          <span>场地名称：</span>
          <el-input v-model="field_ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item prop="english_name">
          <span>场地英文名称：</span>
          <el-input v-model="field_ruleForm.english_name"></el-input>
        </el-form-item>
        <el-form-item prop="telephone">
          <span>场地联系电话：</span>
          <el-input v-model="field_ruleForm.telephone"></el-input>
        </el-form-item>
        <el-form-item prop="discription">
          <span>描述：</span>
          <el-input v-model="field_ruleForm.discription"></el-input>
        </el-form-item>
        <el-form-item>
          <span style="width:80%;text-align:center;">
            <el-button type="primary" @click="submitForm('field_ruleForm')">提交</el-button>
            <el-button type="primary" @click="resetForm('field_ruleForm')">重置</el-button>
          </span>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: "Add",
  data() {
    return {
      field_ruleForm: {
        // id: "",
        name: "",
        english_name: "",
        telephone: "",
        discription: "",
        create_time: "",
      },
      rules: {
        name: [{ required: true, message: "请输入场地名称", trigger: "blur" }],
        english_name: [
          { required: true, message: "请输入场地英文名称", trigger: "blur" },
        ],
        telephone: [
          {
            required: true,
            message: "请输入场地联系电话号码",
            trigger: "blur",
          },
        ],
        discription: [
          { required: true, message: "请输入场地描述", trigger: "blur" },
        ],
      },
    };
  },
  methods: {
    //添加场地提交
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },

    //表单重置
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>


<style scoped>
#container {
  width: 80%;
  margin: auto;
  font-size: 20px;
}
span {
  display: inline-block;
  width: 200px;
  font-size: 20px;
  text-align: right;
}
</style>
<style>
#field_ruleForm .el-form-item {
  /* display: inline-block;
  text-align: center; */
  height: 50px;
  line-height: 50px;
}
#field_ruleForm .el-form-item .el-input {
  width: 400px;
  text-align: left;
  height: 50px;
  line-height: 50px;
}
</style>
